package com.entity;

import java.util.ArrayList;
import java.util.List;

public class Student {
	
	private String number;
	
	private String name;
	
	private String sex;
	
	private List<String> like;
	
	public String getJsonStr() {
		
		List<String> list = new ArrayList<String>();
		if( this.getNumber() != null) {
			list.add("\"number\":\""
					+ this.getNumber() +"\"");
		}
		if( this.getName() != null ) {
			list.add("\"name\":\"" 
						+ this.getName() + "\"");
		}
		if( this.getSex() != null ) {
			list.add("\"sex\":\"" 
						+ this.getSex() + "\"");
		}
		if( this.getLike() != null 
				&& this.getLike().size() > 0) {
			list.add("\"like\":[\"" 
						+ String.join("\",\"", this.getLike()) 
						+ "\"]" );
		}
		if( list.size() > 0 ) {
			return "{" + String.join(",",list )+"}";
		}
		return "{}";
	}
	
	
	
	/**
	 * @return the number
	 */
	public String getNumber() {
		return number;
	}
	/**
	 * @param number the number to set
	 */
	public void setNumber(String number) {
		this.number = number;
	}
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}
	/**
	 * @return the sex
	 */
	public String getSex() {
		return sex;
	}
	/**
	 * @param sex the sex to set
	 */
	public void setSex(String sex) {
		this.sex = sex;
	}
	/**
	 * @return the like
	 */
	public List<String> getLike() {
		return like;
	}
	/**
	 * @param like the like to set
	 */
	public void setLike(List<String> like) {
		this.like = like;
	}
}